#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

string sa[3];
string trans(string ss)
{
	string 	st="";
	for(int i=0;i<ss.size();i++) if(ss[i]!=';'&&ss[i]!='-'&&ss[i]!='_')
	{
		if(ss[i]>='A'&&ss[i]<='Z') st+=ss[i]+32;
		else st+=ss[i];
	}
	return st;
}
bool judge(string &ss,int pos)
{
	for(int i=0;i<3;i++)
	{
		if(sa[i]==ss.substr(pos,sa[i].size()))
		{
			if(pos+sa[i].size()==ss.size()) return true;
			else if(judge(ss,pos+sa[i].size())) return true;
		}
	}
	return false;
}
int main()
{
	int n;
	string ss;
	for(int i=0;i<3;i++) cin>>sa[i],sa[i]=trans(sa[i]);
	cin>>n;
	while(n--)
	{
		cin>>ss;
		ss=trans(ss);
		if(judge(ss,0)) cout<<"ACC"<<endl;
		else cout<<"WA"<<endl;
	}
	return 0;
}
